import allure
from selenium.webdriver.common.by import By

from common.base_page import BasePage
from page.emplist_page import EmplistPage


class MainPage(BasePage):
    INDEX_URL = "https://work.weixin.qq.com/wework_admin/frame#index"
    __CONTACT_BUTTON = (By.ID, 'menu_contacts')

    def login(self):
        with allure.step("登录进入首页"):
            # 进入首页
            self.open_url(self.INDEX_URL)
            # 读取cookie，完成登录
            self.login_by_cookie()
            return self

    def goto_emp_list(self):
        """
        进入通讯录页面
        :return:
        """
        with allure.step("登录进入首页"):

            # 1. 点击通讯录按钮
            self.find_ele(self.__CONTACT_BUTTON).click()
            return EmplistPage(self.driver)

